package day1.dao;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class DaoFactory {

	
	private UserDao userDao=null;
	private static DaoFactory instance=new DaoFactory();
	
	private DaoFactory(){
		try {
			InputStream in=DaoFactory.class.getClassLoader().getResourceAsStream("daoconfig.properties");
			Properties properties=new Properties();
			properties.load(in);
			String userDaoClass=properties.getProperty("userDaoClass");
			Class clazz=Class.forName(userDaoClass);
			userDao=(UserDao) clazz.newInstance();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			throw new ExceptionInInitializerError(e);
		}
	}
	
	public static DaoFactory getInstance() {
		return instance;
	}

	public UserDao getUserDao() {
		return userDao;
	}
}
